package com.arron.localvariable;

/**
 * @Classname Exam
 * @Description TODO
 * @Date 2020/8/16 18:38
 * @Created by 刘
 */

public class Exam {

    static int s;
    int i;
    int j;
    {
        System.out.println("i="+i+"j="+j+"s="+s);
        int i=1;
        i++;
        j++;
        s++;
    }

    public void test(int j){
        i++;
        j++;
        s++;
    }

    /**
     * 局部变量，就近原则
     * @param args
     */
    public static void main(String[] args) {

        Exam obj1 = new Exam();
        Exam obj2 = new Exam();

        obj1.test(10);
        obj1.test(20);
        obj2.test(30);

        System.out.println("i="+obj1.i);//2
        System.out.println("j="+obj1.j);//1
        System.out.println("s="+obj1.s);//5 x
        System.out.println("======================");
        System.out.println("i="+obj2.i);//1
        System.out.println("j="+obj2.j);//1
        System.out.println("s="+obj2.s);//5 x

    }



}
